package com.mtr.databoard.domain.middlewares;

import com.mtr.databoard.domain.Entity;
import com.mtr.databoard.domain.components.ViewComponent;

import java.util.Date;
import java.util.List;
import java.util.UUID;

public class Middleware extends Entity<UUID> implements Cloneable{

    private MiddlewareResource cover;
    private String name;
    private String description;
    private MiddlewareResource middleware;
    private String middlewareEntry;
    private Date updateTime;
    private long updateFrequency;
    private List<Parameter> parameters;
    private boolean isPush;

    public String getMiddlewareEntry() {
        return middlewareEntry;
    }

    public void setMiddlewareEntry(String middlewareEntry) {
        this.middlewareEntry = middlewareEntry;
    }

    public MiddlewareResource getCover() {
        return cover;
    }

    public void setCover(MiddlewareResource cover) {
        this.cover = cover;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public MiddlewareResource getMiddleware() {
        return middleware;
    }

    public void setMiddleware(MiddlewareResource middleware) {
        this.middleware = middleware;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public long getUpdateFrequency() {
        return updateFrequency;
    }

    public void setUpdateFrequency(long updateFrequency) {
        this.updateFrequency = updateFrequency;
    }

    public List<Parameter> getParameters() {
        return parameters;
    }

    public void setParameters(List<Parameter> parameters) {
        this.parameters = parameters;
    }

    public boolean getIsPush() {
        return isPush;
    }

    public void getIsPush(boolean push) {
        isPush = push;
    }

    public Middleware() {
        this.setId(UUID.randomUUID());
        this.updateTime = new Date();
    }

    public Middleware(MiddlewareResource cover, String name,String description, MiddlewareResource middleware,String middlewareEntry, long updateFrequency, List<Parameter> parameters, boolean isPush) {
        this.setId(UUID.randomUUID());
        this.cover = cover;
        this.name = name;
        this.description = description;
        this.middleware = middleware;
        this.middlewareEntry = middlewareEntry;
        this.updateTime = new Date();
        this.updateFrequency = updateFrequency;
        this.parameters = parameters;
        this.isPush = isPush;
    }

    public void update(MiddlewareResource cover, String name, String description, MiddlewareResource middleware,String middlewareEntry, long updateFrequency, List<Parameter> parameters, boolean isPush) {
        this.cover = cover;
        this.name = name;
        this.description = description;
        this.middleware = middleware;
        this.middlewareEntry = middlewareEntry;
        this.updateFrequency = updateFrequency;
        this.parameters = parameters;
        this.isPush = isPush;
        this.updateTime = new Date();
    }

    /**
     * 复制
     * @return
     * @throws CloneNotSupportedException
     */
    public Middleware copy() throws CloneNotSupportedException {
        Middleware middleware=(Middleware)this.clone();
        middleware.setId(UUID.randomUUID());
        return middleware;
    }
}
